<?php
@session_start();
if (isset($_SESSION['cus'])) {
    ?>
    <!DOCTYPE html>
    <html>
        <head>
            <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">

            <title></title>
        </head>
        <body> 
            <div id="header">
                <div>
                    <a href="home.php" id="logo"><img src="public/templates/admin/images/logo.png" alt="logo"/></a>
                    <div class="navigation">
                        <ul class="first">
                            <li class="first"><a href="jewelry.html">Hỗ trợ</a></li>

                        </ul>
                        <ul>
                            <?php
                            $conn = mysql_connect('localhost', 'root', '') or die("Not connect to database");
                            mysql_select_db('fashion', $conn) or die("not select to database");
                            mysql_set_charset('utf8', $conn);
                            $sql = "SELECT count(*) as number_promo FROM tbl_promo JOIN tbl_customers ON tbl_promo.cus_id = tbl_customers.cus_id GROUP BY tbl_promo.cus_id HAVING tbl_promo.cus_id = {$_SESSION['cus']['cus_id']}";
                            $result = mysql_query($sql);
                            $rows = mysql_fetch_assoc($result);
                            $name = $_SESSION['cus']['cus_name'];
                            echo '<li class="detail-login">Xin chào:<a href="change.php">' . $name . '</a><a href="km.php">Có ' . $rows['number_promo'] . ' ưu đãi dành cho bạn</a><a href="logout.php">Thoát</a></li>';
                            ?>
                        </ul>
                    </div>
                    <form action="search-key-detail.php?mod=search&act=search_key" method="POST" class="search">
                        <input type="text" value="search" name="keySearch" onblur="this.value=!this.value?'search':this.value;" onfocus="this.select()" onclick="this.value='';"/>
                        <input type="submit" name="search" id="submit" value=''/>
                    </form>
                </div>
                <div id="navigation"><!--END #navigation--->
                    <ul>
                        <li class="selected"><a href="home.php">Trang chủ</a></li>
                        <li><a href="Introduction.php">Giới thiệu</a></li>
                        <li><a href="lienhe.php">Liên hệ</a></li>
                        <li><a href="HD.php">Hướng dẫn mua hàng</a></li>
                        <li><a href="huongdan.php">Góp ý</a></li>
                        <li><a href="km.php">Khuyến mại</a></li>
                    </ul>
                </div>
            </div><!---END #header-->
        </body>
    </html>
    <?php
} else {
    ?>   
    <html>
        <head>
            <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
            <title></title>
        </head>
        <body> 
            <div id="header">
                <div>
                    <a href="home.php" id="logo"><img src="public/templates/admin/images/logo.png" alt="logo"/></a>
                    <div class="navigation">
                        <ul class="first">
                            <li class="first"><a href="jewelry.html">Hỗ trợ</a></li>
                            <li><a href="accessories.html">Sitemap</a></li>
                            <li><a href="blog.html">Bản tin</a></li>
                        </ul>
                        <ul>
                            <li class="link-login"><a href="login-register.php">Đăng ký</a></li>
                            <li class="link-login"><a href="login-register.php">Đăng nhập</a></li>

                        </ul>
                    </div>
                    <form action="search-key-detail.php" method="POST" class="search">
                        <input type="text" value="search" name="keySearch" onblur="this.value=!this.value?'search':this.value;" onfocus="this.select()" onclick="this.value='';"/>
                        <input type="submit" name="search" id="submit" value=''/>
                    </form>
                </div>
                <div id="navigation"><!--END #navigation--->
                    <ul>
                        <li class="selected"><a href="home.php">Trang chủ</a></li>
                        <li><a href="Introduction.php">Giới thiệu</a></li>
                        <li><a href="lienhe.php">Liên hệ</a></li>
                        <li><a href="HD.php">Hướng dẫn mua hàng</a></li>
                        <li><a href="huongdan.php">Góp ý</a></li>
                        <li><a href="km.php">Khuyến mại</a></li>
                    </ul>
                </div>
            </div><!---END #header-->
        </body>
    </html>
    <?php
}
?>
